﻿<UserControl x:Class="MContracts.View.ContractListView"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:converters="clr-namespace:MContracts.Classes.Converters" xmlns:ViewModel="clr-namespace:MContracts.ViewModel" xmlns:Helpers="clr-namespace:MContracts.ViewModel.Helpers" mc:Ignorable="d" 
             d:DesignHeight="300" d:DesignWidth="300" Visibility="{Binding Path=ListVisibility}">
    
    <UserControl.Resources>
        <converters:ContractdocConverter x:Key="ContractdocConverterExtractName" />
        <converters:DateTimeToDateConverter x:Key="DateTimeToRusConverter" />
    </UserControl.Resources>
    
    <Border Margin="0,0,0,0" CornerRadius="0,0,8,0" BorderThickness="2" BorderBrush="Cornsilk" Background="Lavender">
        <Expander IsExpanded="True" HorizontalAlignment="Stretch">
            <Expander.Content>
                <Border Background="LightCoral">
                    <ListBox ItemsSource="{Binding Contracts}">
                        <ListBox.ItemTemplate>
                            <DataTemplate>
                                <Button Style="{StaticResource Flat}" FontSize="12" FontWeight="Medium"  Tag="{Binding}" Command="{x:Static Helpers:Commands.OpenContractCommand}" CommandParameter="{Binding Tag, RelativeSource={RelativeSource Self}}">
                                    <StackPanel>
                                        <TextBlock TextWrapping="WrapWithOverflow" Text="{Binding Converter={StaticResource ContractdocConverterExtractName}}" Width="175" HorizontalAlignment="Center" ></TextBlock>
                                        <Grid>
                                            <Grid.ColumnDefinitions>
                                                <ColumnDefinition Width="Auto"></ColumnDefinition>
                                                <ColumnDefinition Width="*"></ColumnDefinition>
                                            </Grid.ColumnDefinitions>
                                            <Grid.RowDefinitions>
                                                <RowDefinition Height="*"></RowDefinition>
                                                <RowDefinition Height="*"></RowDefinition>
                                                <!--<RowDefinition Height="*"></RowDefinition>-->
                                            </Grid.RowDefinitions>
                                            <!--<Image Grid.Row="0" Source="/MContracts;component/Resources/Signed.png" Width="20" Height="10" ToolTip="Дата подписания"></Image>-->
                                            <Image Grid.Row="0" Source="/MContracts;component/Images/Play.ico"  Width="20" Height="10" ToolTip="Дата начала"></Image>
                                            <Image Grid.Row="1" Source="/MContracts;component/Resources/Apply.png" Width="20" Height="10" ToolTip="Дата окончания"></Image>

                                            <!--<Label Grid.Row="0" Grid.Column="1" FontWeight="Medium" Content="{Binding Approvedat, StringFormat=0:D}"></Label>-->
                                            <Label Grid.Row="0" Grid.Column="1" FontWeight="Medium" Content="{Binding Startat, Converter={StaticResource DateTimeToRusConverter }}"></Label>
                                            <Label Grid.Row="1" Grid.Column="1" FontWeight="Medium" Content="{Binding Endsat, Converter={StaticResource DateTimeToRusConverter }}"></Label>

                                        </Grid>
                                    </StackPanel>
                                </Button>
                            </DataTemplate>
                        </ListBox.ItemTemplate>
                    </ListBox>
                </Border>
            </Expander.Content>
            <Expander.Header>
                <WrapPanel>
                    <Image Width="20" Height="20" ToolTip="{Binding Tooltip}" Source="{Binding ImageResourceName}"></Image>
                    <Label Content="{Binding Title}"></Label>
                </WrapPanel>
            </Expander.Header>
        </Expander>
    </Border>
</UserControl>
